
    function output = third_order_sigma_delta_cifb(X,bit_lev,vref)
        c3 = 1.897825;
        c2 = 1.297825;
        c1 = 0.457008;
        a3 = 0.865340;
        a2 = 0.300000;
        a1 = 0.200000;
        b1 = 0.200000;

        dataLen = length(X);

        v1 = zeros(1, dataLen);      % First integrator output
        v2 = zeros(1, dataLen);      % Second integrator output
        v3 = zeros(1, dataLen);      % Third integrator output
        y  = zeros(1, dataLen);
        Yprev = 0;

        output_step = (vref*2) / (2^(bit_lev-1));

        for n = 1 : dataLen
            if(n > 1)
                v1(n) = X(n)  * b1 - a1 * Yprev + v1(n-1);
                v2(n) = v1(n) * c1 - a2 * Yprev + v2(n-1);
                v3(n) = v2(n) * c2 - a3 * Yprev + v3(n-1);
            else
                v1(n) = X(n)  * b1 - a1 * Yprev + 0;
                v2(n) = v1(n) * c1 - a2 * Yprev + 0;
                v3(n) = v2(n) * c2 - a3 * Yprev + 0;
            end

            y(n)  = c3 * v3(n);


            output(n) = round(y(n) / output_step);
            if(output(n) > (2^(bit_lev-1) -1) )
                output(n) = 2^(bit_lev-1) -1;
            end
            if(output(n) < (-(2^(bit_lev-1) -1)) )
                output(n) = -(2^(bit_lev-1)-1);
            end

            Yprev = output(n)*output_step;
            e(n) = y(n)-Yprev;

        end



    end